nginx_start()
{
    sudo nginx
    if [ $? -ne 0 ];then
        echo "nginx启动失败！"
    else
        echo "nginx启动成功！"
    fi
}

ps aux | grep nginx | grep -v grep > /dev/null
if [ $? -eq 0 ];then
    echo "nginx已经启动。。。"
    echo "尝试重启："
    sudo nginx -s reload
    if [ $? -eq 0 ];then
        echo "nginx重启成功！"
    else
        echo "nginx重启失败！"
    fi
else
    nginx_start
fi